#ifndef GX_DLL_RUNTIME_CALL_H
#define GX_DLL_RUNTIME_CALL_H

#include "Basic/GxLibBasic.h"
#include "windows.h"

namespace GxLibBasic
{

	class gxDllModuleLibrary : public Object
	{
	private:
		Mapping<String,HMODULE> FModules;
	public:
		HMODULE RequireLibrary(String LibName);
		void FreeModules();
		~gxDllModuleLibrary();
	};

	class gxDllVariable : public Object
	{
	public:
		enum gxVariableType
		{
			gxatVoid,
			gxatInt,
			gxatChar,
			gxatWChar,
			gxatDouble,
			gxatFloat,
			gxatInt64
		};
		gxVariableType Type;
		union
		{
			int IntVal;
			char CharVal;
			wchar_t WCharVal;
			double DoubleVal;
			float FloatVal;
			__int64 Int64Val;
		} Data;

		gxDllVariable();
		gxDllVariable(int val);
		gxDllVariable(float val);
		gxDllVariable(double val);
		gxDllVariable(__int64 val);
		gxDllVariable(char val);
		gxDllVariable(wchar_t val);
	};

	class gxDllFunction : public Object
	{
	public:
		enum gxCallConvention
		{
			gxccStdCall,
			gxccCdecl
		};
	private:
		FARPROC FFuncPtr;
	public:
		gxDllFunction(HMODULE lib, String FuncName);
		~gxDllFunction();
	public:
		gxDllVariable Invoke(Array<gxDllVariable>& Args, gxDllVariable::gxVariableType ReturnType, gxCallConvention conv = gxccStdCall);
	};

}

#endif